package com.example.eshop_ssm.util;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

public class GetUtilSqlSessionFactory {
    private static SqlSessionFactory factory;

    static {
        //获取配置文件的输入流
        InputStream resourceAsStream = GetUtilSqlSessionFactory.class.getResourceAsStream("/SQLMapConfig.xml");
        //创建SqlSessionFactory 对象
        factory = new SqlSessionFactoryBuilder().build(resourceAsStream);
    }

    /**
     * 获取 SqlSessionFactory 对象
     * @return
     */
    public static SqlSessionFactory getFactory(){
        return factory;
    }
}
